package Client;

import module.Message;
import module.User;
import java.io.IOException;

/**管理员初始账号：admin 密码：123456
 * @author 长风无言
 */
public class ClientLogin {

    public static void managerlogin(ClientInitClose client) throws IOException, ClassNotFoundException {

        while (true) {
            System.out.println("请输入管理员账号：");
            String uerName = ClientScanner.getScanner().next();
            System.out.println("请输入管理员密码：");
            String password = ClientScanner.getScanner().next();
            Message inform = new Message("managerCheck", new User(uerName, password));
            client.getOut().writeObject(inform);
            System.out.println("账号登陆中...");
            inform = (Message) client.getIn().readObject();
            if ("success".equals(inform.getCheckFlag())) {
                System.out.println("管理员登陆成功！");
                ManageMainPage mm = new ManageMainPage();
                mm.manageMainPage(client);
                return;
            } else {
                System.out.println("管理员登录失败！账户或密码错误，请重新输入：");
            }
        }
    }
}
